package Test;

import java.util.*;

/**
 * @BelongsProject: LeetCode
 * @BelongsPackage: Test
 * @Author: song
 * @CreateTime: 2023-12-04  20:29
 * @Description: TODO
 * @Version: 1.0
 */

public class thisMyTrain {

    public static void main(String[] args) {
        HashSet<Integer> set = new HashSet<>();
        Collections.addAll(set,10,90,20,80,30,70,60,40,50);
        System.out.println(set);
        set.forEach(num-> System.out.print(num + " "));
        System.out.println();
        Iterator<Integer> iterator = set.iterator();
        while (iterator.hasNext()){
            System.out.print(iterator.next()+" ");
        }
        System.out.println();
        for (Integer num:
             set) {
            System.out.print(num + " ");
        }
        /*HashMap<Integer, String> map = new HashMap<>();
        map.put(1,"song");
        map.put(2,"yin");
        map.put(3,"zhong");
        System.out.println(map);
        Set<Integer> keySet = map.keySet();
        for (Integer key:
             keySet) {
            System.out.print(key + "=" + map.get(key) + "\t");
        }
        System.out.println();
        Set<Map.Entry<Integer, String>> entries = map.entrySet();
        for (Map.Entry<Integer,String> entry:
             entries) {
            System.out.print(entry.getKey() + "=" + entry.getValue()+ "\t");
        }*/

        /*ArrayList<Integer> list = new ArrayList<>();
        Collections.addAll(list,98,12,34,56,2,78,101,568);
        System.out.println(list);

        for (int i = 0; i < list.size(); i++) {
            System.out.print(list.get(i) + " " );
        }
        System.out.println();
        for (Integer i : list){
            System.out.print(i + " ");
        }
        System.out.println();
        list.forEach(num-> System.out.print(num + " "));
        Iterator<Integer> iterator = list.iterator();
        while(iterator.hasNext()){
            System.out.print(iterator.next() + " ");
        }
        System.out.println("所有的遍历结果已生成！");*/


    }

    /*public static int[] bubbleSort(int[] nums){
        for (int i = 1; i < nums.length; i++) {
            boolean flag = true; // 设置一个标志位，如果为TRUE的话，表示该轮循环没有经历过数值的交换，
            // 说明这个数组已经有序了，为了减少循环次数，直接跳出循环，返回一个有序的数组即可。
            for (int j = 0; j < nums.length -i; j++){
                if (nums[j] > nums[j + 1]){
                    int temp = nums[j];
                    nums[j] = nums[j + 1];
                    nums[j+1] = temp;
                    flag = false;
                }
            }
            if (flag)
                break;
        }
        return nums;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String numsLine = in.nextLine();
        String[] strings = numsLine.split(" ");
        int n =strings.length;
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = Integer.parseInt(strings[i]);
        }
        int[] sort = bubbleSort(nums);
        System.out.println(Arrays.toString(sort));
    }*/
}
